package day0918;

import java.util.Map;
import java.util.TreeMap;

class  Student implements Comparable{
    int stuNo;
    public Student(int stuNo) {
        this.stuNo = stuNo;
    }
    public int compareTo(Object o) {
        Student oo=(Student)o;
        return oo.stuNo-this.stuNo;//降序
    }
    //实现Comparable必须实现compareto: 减法(升序：this-参数)
}



public class T3_TreeMapTest {
    //TreeMap
    public static void main(String[] args) {
        Map map=new TreeMap();
        map.put("1001", new Student(1001));
        map.put("1002", new Student(1002));
        //迭代器打印
    }
}








